/************************************************************
 * Copyright (C), 2022-2030, ripnano. Co., Ltd.
 * FileName:        form_setting_log.h
 * Author:          Dan Yin
 * Date:            2023-08-14
 * Description:     the class of log info window
 * Version:         1.0.0.0
 **********************************************************/

#ifndef FORM_SETTING_LOG_H
#define FORM_SETTING_LOG_H

// add necessary includes here
#include "ui/defines/global.h"


namespace Ui {
class FormSettingLog;
}

class FormSettingLog : public QWidget
{
    Q_OBJECT

public:
    // Get an instance of "FormSettingLog" class, if exist, return it
    static FormSettingLog* getInstance(QWidget *pParent = nullptr);

signals:
    // The signal that refresh UI info
    void signalRefreshUI();

    // Switch the language(English/Chinese)
    void signalSwitchLanguage(int eumLangType);

    // Display error info on status
    void signalDisplayErrorInfoOnStatus(int nLevel, QString sErrDesc);

private slots:
    // The slot that refresh UI info
    void slotRefreshUI();

    // Receive a payload data from serialport (error log)
    void slotErrorLogPayload(unsigned int unCanId, int nLevel, int nCoding);

    void on_pushButton_LastPage_clicked();

    void on_pushButton_NextPage_clicked();

protected:
    // Triggers an event before it is switch language
    void changeEvent(QEvent *event);

private:
    // The default constructor
    explicit FormSettingLog(QWidget *parent = nullptr);

    // The default destructor
    virtual ~FormSettingLog();

    // After constructing object, initialize the object
    void _initialze();

    // Init the window style
    void _initUi();

    // Display the log data list by paging
    int _displayLogListByPaging(int & nRecordCnt, int & nListCnt, int nLimit = 0, int nOffset = 0);

private:
    Ui::FormSettingLog *ui;

    QStandardItemModel *m_pModelItem = nullptr;
};

#endif // FORM_SETTING_LOG_H
